package com.example.servlet.request;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @program: sms
 * @description:
 * @author: zhanghz001
 * @create: 2020-11-02 14:57
 **/
@WebServlet("/demoaaa/demo01")
public class RequestDemo01 extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        System.out.println("=========各种路径======");
        System.out.println(req.getLocalAddr());
        System.out.println(req.getServerName());
        System.out.println(req.getLocalName());
        System.out.println(req.getLocalPort());
        //远端的
        System.out.println(req.getRemoteAddr());
        System.out.println(req.getRemoteHost());
        System.out.println(req.getRemotePort());
        //路径
        //统一资源定位符
        System.out.println(req.getRequestURL().toString());
        //统一资源标识符
        System.out.println(req.getRequestURI());
        System.out.println(req.getQueryString());
        System.out.println(req.getServletPath());

    }
}
